<?php

/**
 * PlugintmcContact form.
 *
 * @package    ##PROJECT_NAME##
 * @subpackage form
 * @author     ##AUTHOR_NAME##
 * @version    SVN: $Id: sfDoctrineFormPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
abstract class PlugintmcContactForm extends BasetmcContactForm
{
  public function  setup() {
    parent::setup();
    unset(
      $this['created_at'], $this['updated_at']
    );
    $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('tmcContactPlugin');
    $subject_options = sfConfig::get('app_tmcContactPlugin_subject_widget');
    if ( array_key_exists('enabled', $subject_options) ){
      if ( ! $subject_options['enabled'] ){
        unset($this['subject']);
      }else{
        if (in_array('type', $subject_options) && $subject_options['type'] == 'choice'){
          $this->widgetSchema['subject'] = new sfWidgetFormChoice(array(
             'choices' => is_array($subject_options['choices']) ? $subject_options['choices'] : array(),
          ));

          $this->validatorSchema['subject'] = new sfValidatorChoice(array(
             'choices' => is_array($subject_options['choices']) ? array_keys($subject_options['choices']) : array(),
          ));
        }
      }
    }

    $this->validatorSchema['email'] = new sfValidatorEmail(array(
      'required' => true
    ));
  }
}
